// 引入less
require("./zjf-sport-introduce.less");
// 引入axios
const axios = require("axios");
document.addEventListener("DOMContentLoaded", function () {
	// 获取方法
	function $(v) {
		return document.querySelector(v);
	}
	// 返回键
	$("#lt").addEventListener("click", function () {
		location.href = "./zjf-sport-course.html";
	});
	axios.defaults.baseURL = "http://fitness.h5.itsource.cn:3701";
	let token = localStorage.getItem("token");
	axios.defaults.headers.common["Authorization"] = "Bearer " + token;
	let id = location.search.split("=").pop();
	axios.get("/api/train/courseDetail?id=" + id).then((v) => {
		let data = v.data.data;
		console.log(data);
		localStorage.setItem("data", JSON.stringify(data));
		$("#video").src = axios.defaults.baseURL + data.fragments[0].videoUrl;
		$("#calorie").textContent = data.calorie;
		$("#time").textContent = data.time;
		$("#title h2").textContent = data.name;
	});
	$("#btn").addEventListener("click", function () {
		console.log(1);
		location.href = "./zjf-sport-video.html";
	});
});
